package com.siqi.hr.system.organization.dao.mysql;

import com.siqi.hr.system.organization.dao.intf.RoleMenuDao;
import com.siqi.hr.system.organization.entity.RoleMenu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 * 角色、菜单关系dao接口实现类
 * @author     xiaogq
 * Created by xiaogoingqin on 2016/8/30.
 */
@Repository("roleMenuDao")
public class RoleMenuDaoImpl implements RoleMenuDao{

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public void addRoleMenu(RoleMenu roleMenu) {
        StringBuffer sql = new StringBuffer("insert into sys_org_role_menu(role_id,menu_id)  values('"+roleMenu.getRole().getId()+"',"+roleMenu.getMenu().getId()+")");
        try {
            jdbcTemplate.execute(sql.toString());
        } catch (DataAccessException e) {
            e.printStackTrace();
        }
    }
}
